
window.onload = function (){
	document.getElementById("MemberResumeNote").onkeyup();
	var hwlflg = document.getElementsByName("Memberhwlf");
	for (var i=1; i<hwlflg.length; i++){
		Element.hide(hwlflg[i]);
		document.getElementById("thMemberHopeWorkLocation").setAttribute("rowspan","2");
	}
	var hidlist = new Array('MemberOverseasEdu','MemberOverseasWork','MemberLang','MemberExpWorktype','MemberHopeWorkLocation','MemberHopeWorktype','MemberHopeCategory');
	for(var i=0; i<hidlist.length; i++){
		var maxcount = 3;
		var hidemoebtn = document.getElementsByName("btnAdd"+hidlist[i]);
		var tablelist = document.getElementsByName("table"+hidlist[i]);
		if(tablelist.length>1){
			if(hidlist[i]=="MemberExpWorktype"){
				document.getElementById("th"+hidlist[i]).setAttribute("rowspan","4");
			}else{
				document.getElementById("th"+hidlist[i]).setAttribute("rowspan","3");
			}
		}
		
		if(hidlist[i]=="MemberExpWorktype"){
			if(document.getElementsByName("tableMemberExpWorktype").length>0){
				Element.hide("btnDel"+hidlist[i]+"0");
			}
		}else{
			Element.hide("btnDel"+hidlist[i]+"1");
		}
		if(hidlist[i]=="MemberLang"){
			maxcount = 5;
		}else{
			maxcount = 3;
		}
		for(var j=1; j<=hidemoebtn.length-1; j++){
			Element.hide(hidemoebtn[j-1]);
			if( hidlist[i] != 'MemberHopeWorkLocation'){
				Element.hide("trAdd"+hidlist[i]);
			}
		}
		if(hidemoebtn.length==maxcount ){
			Element.hide(hidemoebtn[maxcount-1]);
			
			if( hidlist[i] != 'MemberHopeWorkLocation'){
				Element.hide("trAdd"+hidlist[i]);
			}
		}
	}
	document.getElementById("MemberWorkVisaFlg").onclick();
	disabledHopeWorkLocation(document.getElementById("MemberHopeWorkLocationFlg"),'onload');
	disabledHopeCategory(document.getElementById("MemberHopeCategoryFlg"),'onload');
	disabledHopeWorktype(document.getElementById("MemberHopeWorktypeFlg"),'onload');
	disabledHopeIncome(document.getElementById("MemberHopeIncomeFlg1"));
	showOther(document.getElementById("MemberNationalityId"));
	var htmlvalid = document.getElementById('htmlValid').value;
	if(htmlvalid != ''){
		var obj = htmlvalid.split(",");
		for(var i=0; i<(obj.length);i++){
			//document.getElementById(obj[i]).className = "wrong_color";
			var classname = document.getElementById(obj[i]).className
			document.getElementById(obj[i]).className = classname+ " input_redcolor";
		}
	} 
	document.getElementById("MemberHopeIncome").onchange();
	document.getElementById("MemberHopeIncomeTo").onchange();
}

function checkWord(len,op){ 
	var str = op.value.trim();
	myLen =0;
	i=0;
	for(;(i<str.length)&&(myLen<=len*2);i++){
		if(str.charCodeAt(i)>0&&str.charCodeAt(i)<128){
			myLen++;
		}else{
			myLen+=2;
		}
	}
	var mydiv=document.getElementById("wordCheck");
	if(myLen>len*2){
		//@author wangyuhua 4/23 update start 注释下面的错误代码，重新改写代码
//		src.value=str.substring(0,i-1);
		str = str.substring(0,i-1);
		document.getElementById("MemberResumeNote").value = (str);
		//@author wangyuhua 4/23 update end
	}
	else{
		var word = Math.floor((len*2-myLen)/2);
		document.getElementById("MemberResumeNoteWord").value = (len-word);
		document.getElementById("wordCheck").innerHTML = "<span>"+word+"</span>";
	}
}

function formatMoney(num,n)
{
	var oldNum = num;
	num = (num + "").replace(/[^\d\.-]/g, "");
	if(num == ''){
		 return oldNum;
	}
	num = parseFloat(num);

	num = num.toFixed(n) + "";  
    var re = /(-?\d+)(\d{3})/;
    while(re.test(num)) num = num.replace(re,"$1,$2")
    return num;
}

function openChangeWorkYm(id) {
	Dialog.alert($(id).innerHTML,{
				 className: "alphacube",
				 width:300,
				 id: "d" + id, 
				 okLabel: "保存する",
				 buttonClass:"bt3",
				 closable:true,
				 ok:function(){
					var selChangeWorkYm=document.getElementsByName("data[RMember][change_work_ym]")[0];
					document.getElementById("hidChangeWorkYm").value=selChangeWorkYm.options[selChangeWorkYm.options.selectedIndex].value;
					document.getElementById("lblChangeWorkYm").innerHTML=selChangeWorkYm.options[selChangeWorkYm.options.selectedIndex].value;
					Windows.close("d" + id);}
				})
}

function showOther(e) {
	var others_div = document.getElementById("others_div");
  	if(e.options[e.selectedIndex].text == 'その他'){
  		others_div.style.display='inline';
  	}else{
  		document.getElementById('other_language').value='';
  		others_div.style.display='none';
  	}
}

function disabledHopeWorkLocation(obj,op){
	var count = document.getElementById("hidmember_hope_work_location_count").value;
	var flg = document.getElementById("hidmember_hope_work_location_flg").value;
	for(var i =1; i<=3; i++)
	{
		if(flg == 1 && op == 'onload'){
			obj.checked = true;
		}
		if(obj.checked){
			var sel = document.getElementsByName("data[Member][hope_work_location"+i+"]");
			if(sel.length>0){
				sel[0].disabled=true;
			}
			var pm = document.getElementsByName("pMemberHopeWorkLocation");
			for(var j =0; j<pm.length; j++){
				if(j!=0){
					Element.hide(pm[j]);
				}
				if(pm.length==1){
					Element.hide("pMemberHopeWorkLocation");
					document.getElementById("thMemberHopeWorkLocation").setAttribute("rowspan","2");
				}
			}
		}else{
			//salert('123');
			var sel = document.getElementsByName("data[Member][hope_work_location"+i+"]");
			if(sel.length>0){
				sel[0].disabled=false;
			}
			var pm = document.getElementsByName("pMemberHopeWorkLocation");
			for(var j =0; j<pm.length; j++){
				if(j!=0){
					Element.show(pm[j]);
				}
				if(pm.length==1){
					Element.show("pMemberHopeWorkLocation");
					document.getElementById("thMemberHopeWorkLocation").setAttribute("rowspan","3");
				}
			}
			if(count==1){
				Element.show("pMemberHopeWorkLocation");
				document.getElementById("thMemberHopeWorkLocation").setAttribute("rowspan","3");
			}else{
				document.getElementById("thMemberHopeWorkLocation").setAttribute("rowspan","2");
			}
		}	
	}
}

function disabledHopeCategory(obj,op){
	var count = document.getElementById("hidmember_hope_category_count").value;
	var flg = document.getElementById("hidmember_hope_category_flg").value;
	for(var i =1; i<=3; i++)
	{
		if(flg == 1 && op == 'onload'){
			obj.checked = true;
		}
		if(obj.checked){
			var sel = document.getElementsByName("data[Member][hope_category"+i+"]");
			if(sel.length>0){
				sel[0].disabled=true;
			}
			var pm = document.getElementsByName("pMemberHopeCategory");
			for(var j =0; j<pm.length; j++){
				if(j!=0){
					Element.hide(pm[j]);
				}
				if(pm.length==1){
					Element.hide("trAddMemberHopeCategory");
					document.getElementById("thMemberHopeCategory").setAttribute("rowspan","2");
				}
			}
		}else{
			var sel = document.getElementsByName("data[Member][hope_category"+i+"]");
			if(sel.length>0){
				sel[0].disabled=false;
			}
			var pm = document.getElementsByName("pMemberHopeCategory");
			for(var j =0; j<pm.length; j++){
				if(j!=0){
					Element.show(pm[j]);
				}
				if(pm.length==1){
					Element.show("trAddMemberHopeCategory");
					document.getElementById("thMemberHopeCategory").setAttribute("rowspan","3");
				}
			}
			if(count==1){
				Element.show("trAddMemberHopeCategory");
				document.getElementById("thMemberHopeCategory").setAttribute("rowspan","3");
			}else{
				document.getElementById("thMemberHopeCategory").setAttribute("rowspan","2");
			}
		}	
	}
}

function disabledHopeWorktype(obj,op){
	var count = document.getElementById("hidmember_hope_worktype_count").value;
	var flg = document.getElementById("hidmember_hope_worktype_flg").value;
	for(var i =1; i<=3; i++)
	{
		if(flg == 1 && op == 'onload'){
			obj.checked = true;
		}
		if(obj.checked){
			var selbig = document.getElementsByName("data[Member][hope_worktype"+i+"_big]");
			if(selbig.length>0){
				selbig[0].disabled=true;
			}
			var selsmall = document.getElementsByName("data[Member][hope_worktype"+i+"_small]");
			if(selsmall.length>0){
				selsmall[0].disabled=true;
			}
			var pm = document.getElementsByName("pMemberHopeWorktype");
			for(var j =0; j<pm.length; j++){
				if(j!=0){
					Element.hide(pm[j]);
				}
				if(pm.length==1){
					Element.hide("trAddMemberHopeWorktype");
					document.getElementById("thMemberHopeWorktype").setAttribute("rowspan","3");
				}
			}
		}else{
			
			var selbig = document.getElementsByName("data[Member][hope_worktype"+i+"_big]");
			if(selbig.length>0){
				selbig[0].disabled=false;
			}
			var selsmall = document.getElementsByName("data[Member][hope_worktype"+i+"_small]");
			if(selsmall.length>0){
				selsmall[0].disabled=false;
			}
			var pm = document.getElementsByName("pMemberHopeWorktype");
			for(var j =0; j<pm.length; j++){
				if(j!=0){
					Element.show(pm[j]);
				}
				//if(pm.length == 1){
					Element.show("trAddMemberHopeWorktype");
					document.getElementById("thMemberHopeWorktype").setAttribute("rowspan","5");
				//}
			}
			if(count==1){
				Element.show("trAddMemberHopeWorktype");
				document.getElementById("thMemberHopeWorktype").setAttribute("rowspan","5");
			}else{
				document.getElementById("thMemberHopeWorktype").setAttribute("rowspan","4");
			}
		}	
	}
}

function disabledWorkVisaNation(obj){
	//@author wangyuhua 2012/3/8 update
	if(obj.value=='1' || obj.value=='2'){
		document.getElementById("MemberWorkVisaNation").disabled=true;
		document.getElementById("MemberWorkVisaNation").options[0].selected = true;
	}else{
		document.getElementById("MemberWorkVisaNation").disabled=false;
	}
	
}
function disabledHopeIncome(obj){
	if(obj.value=='1' && obj.checked){
		document.getElementById("MemberHopeIncome").disabled=true;
		document.getElementById("MemberHopeIncomeCur").disabled=true;
		document.getElementById("MemberHopeIncomeTo").disabled=true;
		document.getElementById("MemberHopeIncome").className = "i";
		document.getElementById("MemberHopeIncomeTo").className = "i";
		document.getElementById("MemberHopeIncome").value='';
		document.getElementById("MemberHopeIncomeTo").value='';
		document.getElementById("MemberHopeIncomeCur").options[0].selected = true;
	}else{
		document.getElementById("MemberHopeIncome").disabled=false;
		document.getElementById("MemberHopeIncomeTo").disabled=false;
		document.getElementById("MemberHopeIncomeCur").disabled=false;
	}
}
Array.prototype.indexOf = function(val) {
    for (var i = 0; i < this.length; i++) {
        if (this[i] == val) return i;
    }
    return -1;
};
Array.prototype.remove = function(val) {
    var index = this.indexOf(val);
    if (index > -1) {
        this.splice(index, 1);
    }
};
String.prototype.trim = function() 
{ 
	return this.replace(/(^\s*)|(\s*$)/g, ""); 
}
String.prototype.format=function() 
{ 
	if(arguments.length==0) return this; 
	for(var s=this, i=0; i<arguments.length; i++) {
		s=s.replace(new RegExp("\\{"+i+"\\}","g"), arguments[i]); 
		return s; 
	}
};
String.prototype.Right = function(i) { 
	 return this.slice(this.length - i,this.length);
};
	
var numArray9 = new Array(1,2,3,4,5,6,7,8,9);

function getRealStyle(id,styleName) { 
	var element = document.getElementById(id); 
	var realStyle = null; 
	if (element.currentStyle) {
		realStyle = element.currentStyle[styleName]; 
	}
	else if (window.getComputedStyle) {
		realStyle = window.getComputedStyle(element,null)[styleName]; 
	}
	return realStyle; 
} 

function checkworktype(element,index){

}

function checkMultiLine(element,exp,count){
	var flag = false;
	var elements = $$('#'+element+' '+exp+'');
	var ellength = elements.length;
	var elcount = (ellength/count);
	var ckcount = 0;
	var col = 0;
	for(var j = 1; j<=elcount; j++){
		var m = 0;
		for(var i = 1; i<=ellength; i+=count){
			flag = false;
			if(ckcount!=0)break;
			for(var g = 1; g<=count; g++){
				var element = elements[m];
				var elval = element.options[element.options.selectedIndex].value;
				if(elval != ''){
					ckcount = 0;
					flag = true;
				}
				if((elval == '') && !flag){
					ckcount = i;
				}
				m++;
			}
			col++;
		}
	}
	
	col = col == 0 ? 1 : col;
	if(!flag){
		alert('{0}件目のデータが未入力です。'.format(col));
		return false;
	}else{
		return true;
	}

}

var moeArray = new Array(2,3);
function showMemberOverseasEdu(op,i){
	
	if(!checkMultiLine('parentdivMemberOverseasEdu','select',3)) return false;
	
	var namelist = document.getElementsByName(op.parentNode.parentNode.parentNode.parentNode.parentNode.id);
	var url = '/member/ajax_member_overseas_edu';
	var g = i;
	moeArray.remove(i);
	i=moeArray[0];
	moeArray.remove(i);
	url = url +'?toid='+i+'&ofid='+g;
	
	if(namelist.length >= 3){
		Element.hide(op);
		return false;
	}else if(namelist.length == 1){
		document.getElementById("thMemberOverseasEdu").setAttribute("rowspan","3");
		var element = op.parentNode.parentNode.parentNode;
		Element.hide(element);
	}else{
		Element.hide(op);
	}
	var myAjax = new Ajax.Request(url,{
						            method: 'get',
						            onComplete: function (response) {
						            	new Insertion.Before('ajax_member_overseas_edu', response.responseText); 
						            	document.getElementById("hidmember_overseas_edu_count").value=namelist.length;
						            	if(namelist.length == 3){
						            		Element.hide("btnAddMemberOverseasEdu"+i);
						            	}
						            },
						            asynchronous:true, 
									evalScripts:true
        });
}
function hideMemberOverseasEdu(op,i,g){
	var element = op.parentNode.parentNode.parentNode.parentNode.parentNode;
	var listlength = document.getElementsByName(element.id).length;
	if(listlength==1){
		Element.hide(op);
		return false;
	}
	moeArray.push(i);
	Element.remove(element);
	var addlist = document.getElementsByName("btnAddMemberOverseasEdu");
	Element.show(addlist[addlist.length-1].id);
	if(listlength<=2){
		document.getElementById("thMemberOverseasEdu").setAttribute("rowspan","4");
		Element.show("trAddMemberOverseasEdu");
	}
	document.getElementById("hidmember_overseas_edu_count").value=listlength-1;
}

var mowArray = new Array(2,3);
function showMemberOverseasWork(op,i){
	if(!checkMultiLine('parentdivMemberOverseasWork','select',3)) return false;
	var namelist = document.getElementsByName(op.parentNode.parentNode.parentNode.parentNode.parentNode.id);
	var url = '/member/ajax_member_overseas_work';
	var g = i;
	mowArray.remove(i);
	i=mowArray[0];
	mowArray.remove(i);
	url = url +'?toid='+i+'&ofid='+g;
	
	if(namelist.length >= 3){
		Element.hide(op);
		return false;
	}else if(namelist.length == 1){
		document.getElementById("thMemberOverseasWork").setAttribute("rowspan","3");
		var element = op.parentNode.parentNode.parentNode;
		Element.hide(element);
	}else{
		Element.hide(op);
	}
	var myAjax = new Ajax.Request(url,{
						            method: 'get',
						            onComplete: function (response) {
						            	new Insertion.Before('ajax_member_overseas_work', response.responseText);
						            	document.getElementById("hidmember_overseas_work_count").value=namelist.length;
						            	if(namelist.length == 3){
						            		Element.hide("btnAddMemberOverseasWork"+i);
						            	}
						            },
						            asynchronous:true, 
									evalScripts:true
        });
}
function hideMemberOverseasWork(op,i,g){
	var element = op.parentNode.parentNode.parentNode.parentNode.parentNode;
	var listlength = document.getElementsByName(element.id).length;
	if(listlength==1){
		Element.hide(op);
		return false;
	}
	mowArray.push(i);
	Element.remove(element);
	var addlist = document.getElementsByName("btnAddMemberOverseasWork");
	Element.show(addlist[addlist.length-1].id);
	if(listlength<=2){
		document.getElementById("thMemberOverseasWork").setAttribute("rowspan","4");
		Element.show("trAddMemberOverseasWork");
	}
	document.getElementById("hidmember_overseas_work_count").value=listlength-1;
}

function resetidnum(name){
	var btnlist = new Array("p","btnAdd","btnDel");
	//plist = document.getElementsByName(btnlist[0]+name);
	addnamelist = document.getElementsByName(btnlist[1]+name);
	delnamelist = document.getElementsByName(btnlist[2]+name);
	for(var i=1; i<=addnamelist.length; i++){
		addnamelist[i-1].id = btnlist[1]+name+i;
		delnamelist[i-1].id = btnlist[2]+name+i;
	}
}

function resetMultiLine(element,exp){
	var elements = $$('#'+element+' '+exp+'');
	var i = 1;
	for(var j = 1; j<=elements.length; j+=2){
		elements[j-1].name = 'data[Member][foreign_lang'+i+']';
		elements[j].name = 'data[Member][foreign_lang_level'+i+']';
		elements[j-1].id = 'MemberForeignLang'+i;
		elements[j].id = 'MemberForeignLangLevel'+i;
		i++;
	}
}

var mlArray = new Array(2,3,4,5);
function showMemberLang(op,i){
	if(!checkMultiLine('parentdivMemberLang','select',2)) return false;
	var namelist = document.getElementsByName(op.parentNode.id);
	var url = '/member/ajax_member_lang';
//	var g = i;
//	for(var j=0; j<=i; j++){
//		mlArray.remove(j);
//	}
//	i=mlArray[0];
//	mlArray.remove(i);
	
	var g = op.id.Right(1);
	i = parseFloat(g)+1;
	url = url +'?toid='+i+'&ofid='+g;
	
	if(namelist.length >= 5){
		Element.hide(op);
		return false;
	}else if(namelist.length == 1){
		document.getElementById("thMemberLang").setAttribute("rowspan","2");
		var element = op.parentNode.parentNode.parentNode;
		Element.hide(element);
	}else{
		Element.hide(op);
	}
	var myAjax = new Ajax.Request(url,{
						            method: 'get',
						            onComplete: function (response) {
						            	new Insertion.Before('ajax_member_lang', response.responseText);
						            	document.getElementById("hidmember_lang_count").value=namelist.length;
						            	resetidnum("MemberLang");
						            	resetMultiLine('parentdivMemberLang','select');
						            	if(namelist.length == 5){
						            		Element.hide("btnAddMemberLang"+i);
						            	}
						            }
        });
}
function hideMemberLang(op,i,g){
	var element = op.parentNode.parentNode.parentNode.parentNode.parentNode;
	var listlength = document.getElementsByName(element.id).length;
	if(listlength==1){
		Element.hide(op);
		return false;
	}
	mlArray.push(i);
	Element.remove(element);
	var addlist = document.getElementsByName("btnAddMemberLang");
	Element.show(addlist[addlist.length-1].id);
	if(listlength<=2){
		Element.show("trAddMemberLang");
		document.getElementById("thMemberLang").setAttribute("rowspan","3");
	}
	document.getElementById("hidmember_lang_count").value=listlength-1;
	resetidnum("MemberLang");
	resetMultiLine('parentdivMemberLang','select');
}

var mewArray = new Array(1,2);
function showMemberExpWorktype(op,i){
	if(!checkMultiLine('parentdivMemberExpWorktype','select',4)) return false;
	var namelist = document.getElementsByName(op.parentNode.parentNode.parentNode.parentNode.parentNode.id);
	var url = '/member/ajax_member_exp_worktype';
	var g = i;
	mewArray.remove(i);
	i=mewArray[0];
	mewArray.remove(i);
	url = url +'?toid='+i+'&ofid='+g;
	
	if(namelist.length >= 3){
		Element.hide(op);
		return false;
	}else if(namelist.length == 1){
		document.getElementById("thMemberExpWorktype").setAttribute("rowspan","4");
		var element = op.parentNode.parentNode.parentNode;
		Element.hide(element);
	}else{
		Element.hide(op);
	}
	var myAjax = new Ajax.Request(url,{
						            method: 'get', 
						            onComplete: function (response){
						            	new Insertion.Before('ajax_member_exp_worktype', response.responseText); 
						            	if(namelist.length == 3){
						            		Element.hide("btnAddMemberExpWorktype"+i);
						            	}
						            }
        }
    );
}
function hideMemberExpWorktype(op,i,g){
	var element = op.parentNode.parentNode.parentNode.parentNode.parentNode;
	var listlength = document.getElementsByName(element.id).length;
	if(listlength==1){
		Element.hide(op);
		return false;
	}
	mewArray.push(i);
	Element.remove(element);
	var addlist = document.getElementsByName("btnAddMemberExpWorktype");
	Element.show(addlist[addlist.length-1].id);
	if(listlength<=2){
		document.getElementById("thMemberExpWorktype").setAttribute("rowspan","5");
		Element.show("trAddMemberExpWorktype");
	}

}

var mwlArray = new Array(2,3);
function showMemberHopeWorkLocation(op,i){
	if(!checkMultiLine('parentdivMemberHopeWorkLocation','select',1)) return false;
	var namelist = document.getElementsByName(op.parentNode.parentNode.parentNode.parentNode.parentNode.id);
	
	var url = '/member/ajax_member_hope_work_location';
	var g = i;
	mwlArray.remove(i);
	i=mwlArray[0];
	mwlArray.remove(i);
	if(i!='undefined'){
		url = url +'?toid='+i+'&ofid='+g;
	}
	if(namelist.length >= 3){
		Element.hide(op);
		return false;
	}else if(namelist.length == 1){
		document.getElementById("thMemberHopeWorkLocation").setAttribute("rowspan","2");
		var element = op.parentNode;
		Element.hide(element);
		Element.hide(op);
	}else{
		Element.hide(op);
	}
	//alert('1111');
	var myAjax = new Ajax.Request(url,{
						            method: 'get', 
						            onComplete: function (response){
						            	new Insertion.Before('ajax_member_hope_work_location', response.responseText);
						            	document.getElementById("hidmember_hope_work_location_count").value=namelist.length;
						            	if(namelist.length == 3){
						            		Element.hide("btnAddMemberHopeWorkLocation"+i);
						            	}
						            },
						            asynchronous:true, 
									evalScripts:true
        }
	
	
    );
	//alert('222');
	
//	if(!checkMultiLine('parentdivMemberHopeWorkLocation','select',1)) return false;
//	var namelist = document.getElementsByName(op.parentNode.parentNode.parentNode.parentNode.parentNode.id);
//	var url = '/member/ajax_member_hope_work_location';
//	var g = i;
//	mhclArray.remove(i);
//	i=mhclArray[0];
//	mhclArray.remove(i);
//	url = url +'?toid='+i+'&ofid='+g;
//	
//	if(namelist.length >= 3){
//		Element.hide(op);
//		return false;
//	}else if(namelist.length == 1){
//		document.getElementById("thMemberHopeWorkLocation").setAttribute("rowspan","2");
//		var element = op.parentNode.parentNode.parentNode;
//		Element.hide(element);
//	}else{
//		Element.hide(op);
//	}
//	var myAjax = new Ajax.Request(url,{
//						            method: 'get', 
//						            onComplete: function (response){
//						            	new Insertion.Before('ajax_member_hope_work_location', response.responseText);
//						            	document.getElementById("hidmember_hope_work_location_count").value=namelist.length;
//						            	if(namelist.length == 3){
//						            		Element.hide("btnAddMemberHopeWorkLocation"+i);
//						            	}
//						            },
//						            asynchronous:true, 
//									evalScripts:true
//        }
//    );	
	
}
function hideMemberHopeWorkLocation(op,i,g){
//	var element = op.parentNode.parentNode.parentNode.parentNode.parentNode;
//	var listlength = document.getElementsByName(element.id).length;
//	if(listlength==1){
//		Element.hide(op);
//		return false;
//	}
//	mwlArray.push(i);
//	Element.remove(element);
//	var addlist = document.getElementsByName("btnAddMemberHopeWorkLocation");
//	Element.show(addlist[addlist.length-1].id);
//	if(listlength<=2){
//		Element.show("pMemberHopeWorkLocation");
//		document.getElementById("thMemberHopeWorkLocation").setAttribute("rowspan","3");
//	}
//	//alert('wqewqe');
//	document.getElementById("hidmember_hope_work_location_count").value=listlength-1;
	
	
	var element = op.parentNode.parentNode.parentNode.parentNode.parentNode;
	var listlength = document.getElementsByName(element.id).length;
	if(listlength==1){
		Element.hide(op);
		return false;
	}
	mwlArray.push(i);
	Element.remove(element);
	var addlist = document.getElementsByName("btnAddMemberHopeWorkLocation");
	
	Element.show(addlist[addlist.length-1].id);
	//alert('222');
	if(listlength<=2){
		
		var element = document.getElementById("pMemberHopeWorkLocation");
		//element.display = "block";
		Element.show("pMemberHopeWorkLocation");
		
		//alert(element);
		document.getElementById("thMemberHopeWorkLocation").setAttribute("rowspan","3");
		
	}
	document.getElementById("hidmember_hope_work_location_count").value=listlength-1;	
	//alert('222');
	
}

var mhclArray = new Array(2,3);
function showMemberHopeCategory(op,i){
	if(!checkMultiLine('parentdivMemberHopeCategory','select',1)) return false;
	var namelist = document.getElementsByName(op.parentNode.parentNode.parentNode.parentNode.parentNode.id);
	var url = '/member/ajax_member_hope_category';
	var g = i;
	mhclArray.remove(i);
	i=mhclArray[0];
	mhclArray.remove(i);
	url = url +'?toid='+i+'&ofid='+g;
	
	if(namelist.length >= 3){
		Element.hide(op);
		return false;
	}else if(namelist.length == 1){
		document.getElementById("thMemberHopeCategory").setAttribute("rowspan","2");
		var element = op.parentNode.parentNode.parentNode;
		//alert(element);
		Element.hide(element);
	}else{
		Element.hide(op);
	}
	var myAjax = new Ajax.Request(url,{
						            method: 'get', 
						            onComplete: function (response){
						            	new Insertion.Before('ajax_member_hope_category', response.responseText);
						            	document.getElementById("hidmember_hope_category_count").value=namelist.length;
						            	if(namelist.length == 3){
						            		Element.hide("btnAddMemberHopeCategory"+i);
						            	}
						            },
						            asynchronous:true, 
									evalScripts:true
        }
    );
}
function hideMemberHopeCategory(op,i,g){
	var element = op.parentNode.parentNode.parentNode.parentNode.parentNode;
	var listlength = document.getElementsByName(element.id).length;
	if(listlength==1){
		Element.hide(op);
		return false;
	}
	mhclArray.push(i);
	Element.remove(element);
	var addlist = document.getElementsByName("btnAddMemberHopeCategory");
	Element.show(addlist[addlist.length-1].id);
	if(listlength<=2){
		document.getElementById("thMemberHopeCategory").setAttribute("rowspan","3");
		Element.show("trAddMemberHopeCategory");
	}
	document.getElementById("hidmember_hope_category_count").value=listlength-1;

}

var mhwlArray = new Array(2,3);
function showMemberHopeWorktype(op,i){
	if(!checkMultiLine('parentdivMemberHopeWorktype','select',2)) return false;
	var namelist = document.getElementsByName(op.parentNode.parentNode.parentNode.parentNode.parentNode.id);
	var url = '/member/ajax_member_hope_worktype';
	var g = i;
	mhwlArray.remove(i);
	i=mhwlArray[0];
	mhwlArray.remove(i);
	url = url +'?toid='+i+'&ofid='+g;
	
	if(namelist.length >= 3){
		Element.hide(op);
		return false;
	}else if(namelist.length == 1){
		document.getElementById("thMemberHopeWorktype").setAttribute("rowspan","4");
		//var element = op.parentNode.parentNode.parentNode;
		Element.hide(op);
	}else{
		Element.hide(op);
	}
	var myAjax = new Ajax.Request(url,{
						            method: 'get', 
						            onComplete: function (response){
						            	new Insertion.Before('ajax_member_hope_worktype', response.responseText);
						            	document.getElementById("hidmember_hope_worktype_count").value=namelist.length;
						            	if(namelist.length == 3){
						            		Element.hide("btnAddMemberHopeWorktype"+i);
						            	}
						            },
						            asynchronous:true, 
									evalScripts:true
        }
    );
}
function hideMemberHopeWorktype(op,i,g){
	var element = op.parentNode.parentNode.parentNode.parentNode.parentNode;
	var listlength = document.getElementsByName(element.id).length;
	if(listlength==1){
		Element.hide(op);
		return false;
	}
	mhwlArray.push(i);
	Element.remove(element);
	var addlist = document.getElementsByName("btnAddMemberHopeWorktype");
	Element.show(addlist[addlist.length-1].id);
	if(listlength<=2){
		document.getElementById("thMemberHopeWorktype").setAttribute("rowspan","4");
		Element.show("trAddMemberHopeWorktype");
	}
	document.getElementById("hidmember_hope_worktype_count").value=listlength-1;

}

//スカウト利用を変わった場合実行する
function profileFlgChange(flg){
	var divSpecial = document.getElementById('divSpecial');
	if(flg == 1) {
		divSpecial.style.display="block";
	} else {
		divSpecial.style.display="none";
	}
}

//削除確認
function deleteConfirm(msg) {
//	window.confirm = function (str) 
//	{
//		execScript("n = msgbox('"+ str +"', 289, '削除確認')", "vbscript"); 
//		return(n == 1); 
//	}
	return window.confirm(msg); 
}


//特別公開企業を削除する
function deleteSpecialCompany(){
	var special = document.getElementsByName('data[special][special_del]');
	var selected = false;
	var company_id = "";
	for(var i=0; i<special.length; i++) {
		if(special[i].checked) {
			selected = true;
			company_id = company_id +',' + special[i].value;
		}
	}
	if(!selected) {
		alert('レコードを1件以上選択してください。');
	} else {
		if(deleteConfirm('一度削除すると該当企業にプロフィールの非公開になります。削除しますか？','NO')) {
			var loadHtml = '<div style="text-align:center" id="loading"><img src="/images/spinner.gif" align="texttop"></div>';
			var url = '/member/delete_special_company';
			var myAjax = new Ajax.Request(url,{
		        method: 'post',
		        onLoading:function(request){
		        	document.getElementById('divSpecial').innerHTML = loadHtml;
				},
		        parameters: {company_id:company_id},
		        onComplete: function (response) {
		        	document.getElementById('divSpecial').innerHTML = response.responseText;
		        },
		        asynchronous:true, 
				evalScripts:true
			});
		}
	}
}
